package com.xmy.service.impl;

import com.xmy.dao.BaseDao;
import com.xmy.entity.User;
import com.xmy.service.UserService;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserServiceImpl extends BaseDao implements UserService {
    @Override
    public User selUser(String userName, String pwd) {
        String sql = "select * from users where userName = ? and password = ?";
        Object[] objects = {userName,pwd};
        User user = null;
        ResultSet rs = null;
        try{
            rs = executeQuery(sql, objects);
            while (rs.next()) {
                user = new User();
                user.setId(rs.getInt(1));
                user.setUserName(rs.getString(2));
                user.setPwd(rs.getString(3));
                user.setRealName(rs.getString(4));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user;
    }
}
